<template>
  <div>
    <a-card :bordered="false">
      <f-search-form :more="false" @searchHandler="searchHandler">
        <f-search-form-item label="标题" name="verTitle"/>
      </f-search-form>
      <f-table ref="table" size="default" rowKey="feedBackId" :columns="columns" :multiple="false" :operator="operator" :params="queryParam" :api="api.feedback">
        <span slot="feedState" slot-scope="text, record, index">
          <a-switch v-model="record.feedState==1" checkedChildren="已处理" unCheckedChildren="未处理" @change="(checked) => setFeedState(checked,record)"/>
        </span>
        <span slot="feedImages" slot-scope="text, record, index">
           <f-images :value="text"></f-images>
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a href="javascript:;" @click="$refs.table.remove(record.feedBackId)">删除</a>
          </template>
        </span>
      </f-table>
    </a-card>
  </div>
</template>

<script>

  import FeedBackDrawer from './feedback_drawer'

  export default {
    name: 'TableList',
    components: {
      FeedBackDrawer
    },
    data() {
      let me = this
      return {
        //列表初始化查询参数
        queryParam: {
          verTitle: ''
        },
        // 表头
        columns: [

          {
            title: '反馈人',
            dataIndex: 'nickName',
            align: 'center'
          },
          {
            title: '反馈状态',
            dataIndex: 'feedState',
            align: 'center',
            scopedSlots: { customRender: 'feedState' }
          },
          {
            title: '反馈内容',
            dataIndex: 'feedContent',
            align: 'center'
          },
          {
            title: '反馈图片',
            dataIndex: 'feedImages',
            align: 'center',
            scopedSlots: { customRender: 'feedImages' }
          },
          {
            title: '反馈日期',
            dataIndex: 'createTime',
            align: 'center'
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: { customRender: 'action' }
          }
        ],
        //操作按钮
        operator: [
          {
            name: '删除',
            icon: 'delete',
            batch: true,
            handler: function(table) {
              table.remove()
            }
          }
        ]
      }
    },
    created() {

    },
    methods: {
      setFeedState(check, record) {
        this.http.post(this, {
          url: this.api.feedback.setState,
          data: {
            ids: record.feedBackId,
            feedState: Number(check)
          },
          success(me, data) {
            record.feedState = data
          }
        })
      }
    }

  }
</script>
